package com.sec.android.app.myfiles.module.search;

import android.content.Context;
import android.net.Uri;
import android.text.TextUtils;

import com.sec.android.app.myfiles.R;
import com.sec.android.app.myfiles.module.abstraction.FileRecord;

public class SearchFileRecord extends FileRecord {

    private FileRecord mPreRecord;

    public SearchFileRecord(int id, String path, String name, long size, long date, int fileType, int isHidden, int itemCount,
                            int itemCountHidden) {
        super(StorageType.Search, id, path, name, size, date, fileType, isHidden, itemCount, itemCountHidden);
    }

    public SearchFileRecord(String searchText) {
        mStorageType = StorageType.Search;
        mPath = "";
        mName = searchText;
    }

    public SearchFileRecord(String folderName, String fileName) {
        mStorageType = StorageType.Search;
        mPath = folderName;
        mName = fileName;
    }

    public void setQuery(String searchText) {
        mName = searchText;
    }

    @Override
    public String getDisplayName(Context context) {
        return context.getString(R.string.menu_search);
    }

    @Override
    public boolean isRoot() {
        return true;
    }

    @Override
    protected int _getId() {
        return 0;
    }

    @Override
    protected Uri _getUri(Context context) {
        return null;
    }

    @Override
    public boolean exists(Context context) {
        return true;
    }

    public FileRecord getPreRecord() {
        return mPreRecord;
    }

    public void setPreRecord(FileRecord preRecord) {
        mPreRecord = preRecord;
    }

    public String getSearchedName() {
        return TextUtils.isEmpty(mName) ? mPath : mName;
    }
}